<template>
  <div>
    <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
      <el-tab-pane label="待评标" name="待评标" />
      <el-tab-pane label="评标结束" name="评标结束" />
    </el-tabs>
    <ClTable
      :key="tableKey"
      ref="refTable"
      :table-data="projectInfoListPage"
      :filter-form-item="filterList"
      :column-list="COLUMN_LIST"
      show-index
    >
      <template #column>
        <el-table-column label="操作" width="240">
          <template #default="{ row }">
            <el-button link type="primary" @click="handleView(row)">查看</el-button>
          </template>
        </el-table-column>
      </template>
    </ClTable>
  </div>
</template>

<script setup lang="ts">
import { COLUMN_LIST, FILTER_FORM_ITEM } from './data'
import { projectInfoListPage } from '@/api/project-info'
import { useProjectInfoStore } from '@/store/projectInfo'
import BidEvaluation from '@/router/modules/bid-evaluation'
import CommonFunctions from '@/router/modules/common-functions'
import router from '@/router'

const filterList = ref(cloneDeep(FILTER_FORM_ITEM))

const { setProjectInfo } = useProjectInfoStore()
const activeName = ref('待评标')
const refTable = ref()
const tableKey = ref(0)
const handleClick = ({ props }) => {
  filterList.value.forEach((item) => {
    if (item.key === 'status') {
      item.value = props.name
    }
  })
  tableKey.value++
}
// 查看
const handleView = async (row: any) => {
  await setProjectInfo(row)
  // 追加路由
  const arr = [BidEvaluation, CommonFunctions]
  arr.forEach((item) => {
    router.addRoute(item)
  })
  router.push({ path: '/bid-evaluation/import-electronic-bid-file' })
}
</script>

<style scoped lang="scss"></style>
